<template>

    <!--筛选条件-->
    <div class="shaixuan2" style="">
        <div style="margin-top: 15px;">
            <span class="title" style="float: left;"> 用户数: {{ persons_online + persons_offline }}人</span>
            <span class="title" style="float: right;">跟进人:
                <!--                    <el-select v-model="userid"  filterable clearable size="small"-->
                <!--                               @change="getPinglunList" placeholder="全部销售">-->
                <el-select v-model="userid" filterable clearable size="small" @change="getPinglunList"
                    placeholder="全部销售">
                    <el-option v-for="item in salerList" :label="item.name" :value="item.userid" :key="item.index">
                    </el-option>
                </el-select>
            </span>
        </div>
        <div class="first_table">
            <el-table :data="msgList"
                style="width: 100%;position:relative;margin-bottom: 20px;height: 680px;overflow-y: auto;" row-key="id"
                border stripe default-expand-all v-loading="loading">

                <el-table-column header-align="left" width="120px" align="left" prop="nickname" label="用户昵称"
                    style="border: 0px !important;" show-overflow-tooltip>
                </el-table-column>
                <!--                    <el-table-column  align="center"  width="100px" header-align="center" prop="avatar" label="用户头像">-->
                <!--                        <template slot-scope="scope">-->
                <!--                            <el-image :src="scope.row.avatar" fit="fill" style="width: 60px;height: 30px;"></el-image>-->
                <!--                        </template>-->
                <!--                    </el-table-column>-->
                <el-table-column header-align="left" width="90px" align="left" prop="saler_name" label="所属助教"
                    show-overflow-tooltip>
                </el-table-column>
                <el-table-column header-align="left" align="left" prop="msg" label="评论内容" show-overflow-tooltip>
                </el-table-column>
            </el-table>
            <!--            <div class="block">-->
            <!--                <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page="pageNumber" :page-sizes="[10, 50, 100, 200]" :page-size="pageSize" background layout="total, sizes, prev, pager, next, jumper" :total="total">-->
            <!--                </el-pagination>-->
            <!--            </div>-->
        </div>
    </div>
</template>

<script>
import TencentCloudChat from "@tencentcloud/chat";
import { getToken } from '@/common/token';

import { getSalerList, getLineUser, getPinglunList, isUserSaler, getSalerInvatationUserIds } from '@/api/live/liveonline';
import { getLiveInfo } from "@/api/live/screen";
export default {
    name: 'PingLunList',
    props: {
        liveId: {
            type: String,
            default: ''
        },
        persons_online: {
            type: Number,
            default: 0
        },
        persons_offline: {
            type: Number,
            default: 0
        }
    },
    data() {
        return {
            title: '',
            anchor_nickname: '',
            anchor_head_img_url: '',
            pageSize: 10, //一页显示多少条
            pageNumber: 1,
            total: 0, //总页数
            input: '',
            tableData: [],
            userid: '',   //销售账号
            loading: false,
            live_id: this.liveId,
            //live_id: this.$route.query.liveId,  // 直播id
            salerInvationUserIds: [], //销售邀请用户
            allSalerInvationUserIds: [],//若欲显示销售,初始化匹配所有销售
            pinglunList: [],
            salerList: [],
            persons_online: this.persons_online,
            persons_offline: this.persons_offline,
            wss: null,  // websocket实例
            wss_url: null,  // websocket地址
            chat: null,  // 腾讯云聊天室实例
            group_id: '',  // 群组id  live_manager chatroom_group_id
            SDKAppID: 1600026179,
            member_id: '',
            member_sign: '',
            admin_id: 'administrator',
            admin_sign: '',
            msgList: [],
            originMessageList: [],
            control_id: '',
            control_sign: ''
        }
    },
    created() {

        // this.getAllSalerInvatationUserIds();
        this.getSalerList();
        this.init();
    },
    watch: {
        title() {
            if (this.title) {
                this.$emit('loadUserProfile', this.title);
            }
        }
    },
    beforeDestroy() {
        // 在组件销毁前执行
        // 在组件销毁前移除IM监听事件处理函数
        this.removeEvents();  // 移除事件监听
        this.disconnect();  // 断开连接
    },
    methods: {
        async init(dateInit = 1) {
            await this.getAllSalerInvatationUserIds();
            // 获取直播信息
            getLiveInfo({
                liveId: this.$route.query.liveId,
                userType: 1
            }).then((res) => {
                if (res.code === 200) {
                    console.log('[control] --获取直播信息成功!', res.data);
                    this.title = res.data.title;
                    this.start_time = res.data.start_time;
                    this.end_time = res.data.end_time;
                    this.SDKAppID = res.data.im_appid;
                    this.status = res.data.status;
                    this.online_person = res.data.total_online_user_num;
                    this.statusInfo = res.data.status_info;
                    this.anchor_nickname = res.data.teacher_name;
                    this.anchor_head_img_url = res.data.face_url;
                    this.live_background_image = res.data.bg_url;
                    this.group_id = res.data.chatroom_group_id;
                    this.userLiveInfo = res.data.userInfo_for_live;
                    console.log('[control] userLiveInfo', this.userLiveInfo);
                    this.member_id = this.userLiveInfo.member_id;
                    this.member_sign = this.userLiveInfo.member_sign;
                    this.admin_id = this.userLiveInfo.admin_id;
                    this.admin_sign = this.userLiveInfo.admin_sign;
                    this.control_id = this.userLiveInfo.control_id;
                    this.control_sign = this.userLiveInfo.control_sign;
                    this.is_im_admin = this.userLiveInfo.is_im_admin;
                    this.tutor_id = this.userLiveInfo.user_id;
                    this.tutor_name = this.userLiveInfo.user_name;
                    this.tutor_avatar = this.userLiveInfo.user_avatar;
                    this.tutor_sign = this.userLiveInfo.user_sign;
                    this.userList = res.data.userList;
                    this.goodList = res.data.good_info;
                    this.goodsList = JSON.parse(res.data.course_sale_ids);
                    this.goodsList = this.goodsList.map(item => Object.assign(item, this.goodList[item.id]));
                    //this.wss_url = `wss://ws.banxued.com/live_control?liveId=${this.live_id}&Authorization=${getToken()}`;
                    // this.msgList = this.msgDispose(res.data.last_msg_list);
                    // this.originMessageList = this.msgDispose(res.data.last_msg_list);

                    console.log('allSalerInvationUserIds', this.allSalerInvationUserIds);
                    //console.log('saler info first',this.salerList);
                    this.msgList = this.msgDispose(res.data.last_msg_list);
                    this.originMessageList = this.msgDispose(res.data.last_msg_list);
                    console.log('msglist test', this.msgList);

                    //当前登录用户为销售，则调用搜索功能
                    //this.isUserSaler();
                    // let last_msg_list = this.msgDispose(res.data.last_msg_list);
                    // this.msgTotalSize = last_msg_list.length; // 消息总条数
                    // this.msgMaxPage = Math.ceil(this.msgTotalSize/this.msgSize); // 消息最大页数
                    // this.msgList = this.msgPages(last_msg_list);
                    // this.msgIllegalList = this.msgDispose(res.data.last_illegal_msg_list);
                    // this.msgForbidList = this.msgDispose(res.data.last_silence_msg_list);
                    // this.msgHideList = this.msgDispose(res.data.last_hide_msg_list);
                    console.log('[control] 初始化消息列表---', this.msgList);
                    console.log('[control] 初始化违禁词消息列表---', this.msgIllegalList);
                    console.log('[control] 初始化禁言消息列表---', this.msgForbidList);
                    console.log('[control] 初始化隐藏消息列表---', this.msgHideList);

                    if (dateInit) {
                        console.log('[control] goodsList', this.goodsList);
                        this.iframeParams = `liveId=${this.live_id}&tutorId=${this.tutor_id}&front_token=${this.userLiveInfo.front_token}`;
                        //this.init_digit_person_list();  // 初始化数字人列表
                        //this.getTime(new Date());  // 获取当前时间并设置时间计数器
                        this.chatInit();  // 初始化聊天
                        //this.getSalerList(); //获取销售列表
                    }
                    // this.init_status();  // 初始化控制状态dd
                    //this.webSocketInit();  // 初始化websocket
                    // if (this.switch_hide_digit_man) {
                    //     this.msgList = this.msgList.map(item => {
                    //         if (item.type === 3 || item.type === 4 ) {
                    //             item.is_digit_man = 1;
                    //         }
                    //         return item;
                    //     });
                    // } else {
                    //     this.msgList = this.msgList.map(item => {
                    //         if (item.type === 3 || item.type === 4 ) {
                    //             item.is_digit_man = 0;
                    //         }
                    //         return item;
                    //     });
                    // }
                } else {
                    console.warn('[control] 获取直播信息状态失败！', res);
                }
            }).catch((err) => {
                console.error('[control] 请求获取直播信息失败！', err);
            });
        },
        //初始化销售列表
        getSalerList() {
            getSalerList({
                "uid": 0,
            }).then((res) => {
                console.log('getSalerList', res);
                if (res.code === 200) {
                    this.salerList = res.data.list;
                    this.salerList.push({ "name": "其它", "userid": "other" })
                }
            })
            return false;
        },
        isUserSaler() {
            isUserSaler({
                "uid": 0,
            }).then((res) => {
                console.log('isUserSaler', res);
                if (res.code === 200) {
                    if (res.data.isOk == true) {
                        this.userid = res.data.userid;
                        this.getPinglunList();
                    }
                }
            })
            return false;
        },
        webSocketInit() {
            this.wss = new WebSocket(this.wss_url);
            this.wss.onopen = (event) => {
                console.log('[control] WebSocket连接已打开！');
                // 在这里你可以发送数据到服务器
            };
            this.wss.onmessage = (event) => {
                // console.log('[control] 收到的WebSocket消息:', event.data);
                // 处理从服务器接收到的数据
                let data = JSON.parse(event.data);
                this.goodList = data.good_info;
                this.goodsList = this.goodsList.map(item => Object.assign(item, this.goodList[item.id]));
                if (data.total_online_user_num !== this.online_person) this.online_person = data.total_online_user_num;
                if (data.status !== this.status) this.status = data.status;
                if (data.status_info !== this.statusInfo) {
                    this.statusInfo = data.status_info;
                    this.init_status();
                }
            };
            this.wss.onerror = (error) => {
                console.error('[control] WebSocket Error: ', error);
            };
            this.wss.onclose = (event) => {
                if (event.wasClean) {
                    console.log('[control] WebSocket 连接已关闭, code=', event.code, 'reason=', event.reason);
                } else {
                    console.error('[control] WebSocket 连接关闭失败', event);
                }
            };
        },
        /*********************** chat 腾讯IM ************************************/
        //初始化
        chatInit() {
            const options = {
                SDKAppID: this.SDKAppID
            };
            //连接im
            this.chat = TencentCloudChat.create(options);
            //设置日志级别
            this.chat.setLogLevel(1);
            // IM绑定事件处理函数
            this.bindEvents();
            // 登录
            this.login();
        },
        // 登录
        login() {
            if (this.chat) {
                this.member_id = this.control_id;
                this.member_sign = this.control_sign;
                //登录账号
                console.log('[control] 登录用户：', this.member_id);

                const options = {
                    userID: this.member_id,
                    userSig: this.member_sign
                };
                this.chat.login(options).then((imResponse) => {
                    console.log('[control] im登录成功！', imResponse);
                    this.joinGroup();
                }).catch((err) => {
                    console.error('[control] im登录失败！', err);
                });
            } else {
                console.error('[control] im未初始化！不能登录！');
            }
        },
        // 登出
        logout() {
            if (this.chat) {
                this.chat.logout().then((imResponse) => {
                    console.log('[control] im登出成功！', imResponse);
                }).catch((err) => {
                    console.error('[control] im登出失败！', err);
                });
            }
        },
        // 关闭连接
        disconnect() {
            if (this.chat) {
                // 销毁 SDK 实例。SDK 会先 logout，然后断开 WebSocket 长连接，并释放资源。
                this.chat.destroy();
                console.log('[control] im连接已关闭');
            }
            if (this.wss) {
                // 关闭 WebSocket 连接
                this.wss.close();
            }
        },
        //加入直播群
        joinGroup() {
            if (this.chat) {
                const options = {
                    groupID: this.group_id,
                    type: TencentCloudChat.TYPES.GRP_AVCHATROOM
                }
                this.chat.joinGroup(options).then((imResponse) => {
                    switch (imResponse.data.status) {
                        case TencentCloudChat.TYPES.JOIN_STATUS_WAIT_APPROVAL:
                            console.log('[control] 等待管理员同意');
                            break;
                        case TencentCloudChat.TYPES.JOIN_STATUS_SUCCESS:
                            console.log('[control] 加群成功', imResponse.data.group); // 加入的群组资料
                            break;
                        case TencentCloudChat.TYPES.JOIN_STATUS_ALREADY_IN_GROUP:
                            console.log('[control] 已经在群中');
                            break;
                        default:
                            console.log('[control] 加群其他未知');
                            break;
                    }
                    // this.setGroupCounters(this.group_id);  // 创建计数key
                    // this.updateGroupProfile();
                }).catch((imError) => {
                    console.warn('[control] 加群 error:', imError); // 申请加群失败的相关信息
                });
            } else {
                console.error('[control] im未连接，无法加入直播群！');
            }
        },
        //退出群组
        quitGroup() {
            if (this.chat) {
                this.chat.quitGroup(this.group_id).then((imResponse) => {
                    // imResponse.data.groupID  退出成功的群 ID
                    console.log('[control] 退出群组成功');
                }).catch((imError) => {
                    console.warn('[control] 退出群组 error:', imError);
                });
            } else {
                console.error('[control] im未连接，无需退出群组');
            }
        },
        //收消息异步处理
        asyncSendMsg(text, nick, id, avatar, icon, noJson) {
            return new Promise((resolve) => {
                setTimeout(() => {

                    if (noJson.type === 1) {
                        if (id.includes('A_') !== -1
                            || id.includes('C_') !== -1
                            || id.includes('administrator') !== -1
                            || id.includes('M_') !== -1) {
                            icon = '助教';
                        }
                    } else if (id.includes('R_') !== -1) {
                        icon = '数字人';
                        noJson.is_digit_man = 1;
                    } else if (noJson.type === 2) {
                        icon = '助教';
                    } else if (noJson.type === 3) {
                        icon = '数字人';
                        if (this.switch_hide_digit_man) {
                            noJson.is_digit_man = 1;
                        }
                    } else if (noJson.type === 4) {
                        icon = '评论组';
                        if (this.switch_hide_digit_man) {
                            noJson.is_digit_man = 1;
                        }
                    } else if (noJson.type === 6) {
                        // 禁言消息
                    } else if (noJson.type === 7 || noJson.msg) {
                        // 违禁词消息
                    }
                    this.sendMsg(text, nick, id, avatar, icon, noJson);
                    resolve();
                }, 300); // 延迟0.3秒钟
            });
        },
        sendMsg(message, nickname, userId, userAvatar, text, json) {
            let isIllegal = 0;  // 违禁词
            let isSilence = 0;  // 禁言
            let isDigitMan = 0;
            if (json.msg) {
                isIllegal = 1;
            }
            if (json.type === 6) {
                // 禁言消息
                isSilence = 1;
            } else if (json.type === 7) {
                // 违禁词消息
                isIllegal = 1;
            }
            if (json.is_digit_man) {
                // 隐藏数字人/评论组
                isDigitMan = 1;
            }
            let saler_name = '';
            if (json.type === 1 || json.type === 2) {
                if (userId.includes('A_')
                    || userId.includes('C_')
                    || userId.includes('administrator')
                    || userId.includes('M_')) {
                }

            } else {
                if (this.allSalerInvationUserIds.hasOwnProperty(userId)) {
                    saler_name = this.allSalerInvationUserIds[userId];
                }
            }
            if (text === '数字人' || isDigitMan === 1) {

            } else {
                this.msgList.unshift({
                    //this.msgList.push({
                    id: userId,
                    msg: message,
                    nickname: nickname,
                    avatar: userAvatar,
                    saler_name: saler_name,
                    no: json.no,
                    type: json.type,
                    icon_text: text,
                    is_illegal: isIllegal,
                    is_silence: isSilence,
                    is_digit_man: isDigitMan,
                    is_hide: 0
                });
                this.originMessageList.unshift({
                    id: userId,
                    msg: message,
                    nickname: nickname,
                    avatar: userAvatar,
                    saler_name: saler_name,
                    no: json.no,
                    type: json.type,
                    icon_text: text,
                    is_illegal: isIllegal,
                    is_silence: isSilence,
                    is_digit_man: isDigitMan,
                    is_hide: 0
                });
            }
        },
        //群提示处理
        asyncTipsProcessing(tip, nick) {
            return new Promise((resolve) => {
                setTimeout(() => {
                    if (tip === 1) {
                        // 有成员加群
                        console.log('有成员加群', nick)
                        //this.$refs.liveSignInRef.welcomeUser(nick);
                    } else if (tip === 10) {
                        // 封禁直播群群成员
                    } else if (tip === 11) {
                        // 解封直播群群成员
                    }
                    resolve();
                }, 2000); // 延迟2秒钟
            });
        },
        //命令处理
        asyncCommandProcessing(cod) {
            return new Promise((resolve) => {
                setTimeout(() => {
                    if (cod.command === 'signIn') {
                        // 进场
                        this.$refs.liveSignInRef.welcomeUser(cod.nick);
                    }
                    resolve();
                }, 2000); // 延迟2秒钟
            });
        },
        /**************** 监听事件 *******************/
        //IM绑定监听事件
        bindEvents() {
            if (this.chat) {
                // 监听im连接打开事件
                this.chat.on(TencentCloudChat.EVENT.SDK_READY, this.onSdkReady.bind(this));

                // 监听WebSocket关闭
                this.chat.on(TencentCloudChat.EVENT.SDK_NOT_READY, this.onSdkNotReady.bind(this));

                // 监听收到推送的单聊、群聊、群提示、群系统通知的新消息
                this.chat.on(TencentCloudChat.EVENT.MESSAGE_RECEIVED, this.onMessageReceived.bind(this));

                // 监听群组计数器更改
                this.chat.on(TencentCloudChat.EVENT.GROUP_COUNTER_UPDATED, this.onGroupCounterUpdated.bind(this));

                // 监听群组事件
                // this.chat.on(TencentCloudChat.EVENT.GROUP_LIST_UPDATED, this.onGroupListUpdated.bind(this));

                // 监听网络状态发生改变
                this.chat.on(TencentCloudChat.EVENT.NET_STATE_CHANGE, this.onNetStateChange.bind(this));
            }

        },
        //IM移除监听事件
        removeEvents() {
            if (this.chat) {
                // 移除监听im连接打开事件
                this.chat.off(TencentCloudChat.EVENT.SDK_READY, this.onSdkReady.bind(this));

                // 移除监听WebSocket关闭 
                this.chat.off(TencentCloudChat.EVENT.SDK_NOT_READY, this.onSdkNotReady.bind(this));

                // 移除监听收到推送的单聊、群聊、群提示、群系统通知的新消息
                this.chat.off(TencentCloudChat.EVENT.MESSAGE_RECEIVED, this.onMessageReceived.bind(this));

                // 移除监听群组计数器更改
                this.chat.off(TencentCloudChat.EVENT.GROUP_COUNTER_UPDATED, this.onGroupCounterUpdated.bind(this));

                // 移除监听群组事件
                // this.chat.off(TencentCloudChat.EVENT.GROUP_LIST_UPDATED, this.onGroupListUpdated.bind(this));

                // 移除监听网络状态发生改变
                this.chat.off(TencentCloudChat.EVENT.NET_STATE_CHANGE, this.onNetStateChange.bind(this));
            }
        },
        /*********************** 监听的回调函数 *********************************/
        // im连接打开时的回调函数  
        onSdkReady(event) {
            console.log('[control] im连接已打开！', event);
            // 消息类型：
            // C2C[私聊]TencentCloudChat.TYPES.CONV_C2C；
            // GROUP[群聊]TencentCloudChat.TYPES.CONV_GROUP
            // this.send('Hello world!', 'GROUP', 'group1');
        },
        // im关闭时的回调函数  
        onSdkNotReady(event) {
            console.log('[control] im连接已关闭！', event);
            // 登录 
            this.chat.login({ userID: 'your userID', userSig: 'your userSig' });
        },
        // 收到推送的单聊、群聊、群提示、群系统通知的新消息时的回调函数
        async onMessageReceived(event) {
            // event.data - 存储 Message 对象的数组 - [Message]
            const messageList = event.data;
            console.log('messageList', messageList);
            for (const message of messageList) {
                console.log('message', message);
                //只处理文本消息，不包括数字人
                if (message.type === TencentCloudChat.TYPES.MSG_TEXT) {

                    // 文本消息
                    console.log('[control] [收]文本', message);
                    console.log(message.cloudCustomData);
                    const noJson = JSON.parse(message.cloudCustomData);
                    await this.asyncSendMsg(message.payload.text, message.nick, message.from, message.avatar, '铁粉', noJson);


                } else if (message.type === TencentCloudChat.TYPES.MSG_FACE) {
                    // 表情消息
                    // console.log('[control] [收]表情');
                } else if (message.type === TencentCloudChat.TYPES.MSG_GRP_TIP) {
                    // 群提示消息
                    // console.log('[control] [收]提示');
                    const { operationType } = message.payload;
                    //await this.asyncTipsProcessing(operationType, message.nick);
                } else if (message.type === TencentCloudChat.TYPES.MSG_GRP_SYS_NOTICE) {
                    // 群系统通知
                    // console.log('[control] [收]通知');
                    const { operationType, userDefinedField } = message.payload;
                    // operationType - 操作类型 [255：用户自定义字段]
                    // userDefinedField - 用户自定义字段（对应 operationType 为 255）
                    // 使用 RestAPI 在群组中发送系统通知时，接入侧可从 userDefinedField 拿到自定义通知的内容。
                    if (operationType === 255) {
                        //命令处理
                        //await this.asyncCommandProcessing(JSON.parse(userDefinedField))
                    }
                }
            }
            // console.log('[control] 收到服务器内容：', event.data);
        },
        // 计数器更改回调函数
        onGroupCounterUpdated(event) {
            const { groupID, key, value } = event.data;
            console.log('[control] 计数器回调：', event.data);
            // groupID - 群组 ID
            // key - 群计数器 key
            // value - 群计数器 key 对应的 value
        },
        // 网络状态发生改变的回调函数
        onNetStateChange(event) {
            // event.data.state 当前网络状态，枚举值及说明如下：
            // TencentCloudChat.TYPES.NET_STATE_CONNECTED - 已接入网络
            // TencentCloudChat.TYPES.NET_STATE_CONNECTING
            // 连接中。很可能遇到网络抖动，SDK 在重试。接入侧可根据此状态提示“当前网络不稳定”或“连接中”
            // TencentCloudChat.TYPES.NET_STATE_DISCONNECTED
            // 未接入网络。接入侧可根据此状态提示“当前网络不可用”。SDK 仍会继续重试，若用户网络恢复，SDK 会自动同步消息
            console.log('[control] im网络变化啦', event.data.state);
        },
        //消息列表处理
        msgDispose(arr) {
            if (arr.length === 0) return [];
            arr = arr.map(item => {
                item.icon_text = '铁粉';
                if (item.hasOwnProperty('im_id')) {
                    if (item.im_id.startsWith('A_')
                        || item.im_id.startsWith('C_')
                        || item.im_id.indexOf('administrator') !== -1
                        || item.im_id.startsWith('M_')) {
                        item.icon_text = '助教';
                    } else if (item.im_id.indexOf('R_') !== -1 || item.type === 3) {
                        item.icon_text = '数字人';
                    } else if (item.im_id.indexOf('P_') !== -1 || item.type === 4) {
                        item.icon_text = '评论组';
                    } else if (item.type === 6) {
                        item.is_silence = 1;
                    } else if (item.type === 7) {
                        item.is_illegal = 1;
                    }
                } else {
                    if (item.type === 2) {
                        item.icon_text = '助教';
                    } else if (item.type === 3) {
                        item.icon_text = '数字人';
                    } else if (item.type === 4) {
                        item.icon_text = '评论组';
                    } else if (item.type === 6) {
                        item.is_silence = 1;
                    } else if (item.type === 7) {
                        item.is_illegal = 1;
                    }
                }
                if (item.icon_text == '助教' || item.icon_text == '数字人') {
                    item.saler_name = '';
                } else {
                    item.saler_name = '';  //需匹配
                    if (this.allSalerInvationUserIds.hasOwnProperty(item.id)) {
                        item.saler_name = this.allSalerInvationUserIds[item.id];
                    }
                }
                return item;
            });
            arr = arr.filter(item => item.icon_text !== '数字人')  //数字人
                .filter(item => item.is_digit_man !== 1);
            //.filter(item=>item.is_illegal !==1);
            // .filter(item=>item.is_silence !==1);
            // arr = arr.filter(item=>item.type === 3)   //数字人
            //     .filter(item=>item.im_id.indexOf('R_') !==-1)  //数字人
            //     .filter(item=>item.is_illegal !==1)
            //     .filter(item=>item.is_silence !==1);
            return arr;
        },
        getAllSalerInvatationUserIds() {

            return new Promise(resolve => {
                // 存在异步情况
                setTimeout(() => {
                    getSalerInvatationUserIds({
                        userid: 'other',
                        liveId: this.liveId
                    }).then((res) => {
                        console.log('---salerInvationUserIds---', res);
                        if (res.code === 200) {
                            this.allSalerInvationUserIds = res.data.userIdSalerUserIdList;
                        }
                    })
                    resolve();
                }, 1000)
            })

            // getSalerInvatationUserIds({
            //     userid: 'other'
            // }).then((res)=>{
            //     console.log('salerInvationUserIds', res);
            //     if(res.code === 200){
            //         this.allSalerInvationUserIds = res.data.userIdSalerUserIdList;
            //     }
            // })
            return false;
        },
        getPinglunList() {

            let a = JSON.stringify(this.originMessageList);
            let b = JSON.parse(a);
            if (this.userid) {
                this.msgList = b;
            }
            getSalerInvatationUserIds({
                userid: this.userid,
                liveId: this.liveId
            }).then((res) => {
                console.log('salerInvationUserIds', res);
                if (res.code === 200) {
                    // alert(res.data.list.length);return false;
                    this.salerInvationUserIds = res.data.list;
                    this.getSalerInvatationUserId();
                }
            })
            return false;
        },
        getSalerInvatationUserId() {
            //根据销售id,对数组进行过滤,所属销售账户
            let a = JSON.stringify(this.originMessageList);
            let b = JSON.parse(a);
            if (this.userid) {
                console.log('filter pinglun start');
                console.log("saler info", this.userid);

                if (this.userid == "other") {

                    console.log('other');
                    let c = b.filter(
                        item => !this.salerInvationUserIds.includes(item.id)
                    );
                    this.msgList = c;

                } else {
                    console.log('no other');
                    let c = b.filter(
                        item => this.salerInvationUserIds.includes(item.id)
                    );
                    this.msgList = c;
                }

            } else {
                this.msgList = b;
            }
            this.msgList = this.msgDispose(this.msgList);
            console.log('originMessageList', this.originMessageList);
            console.log('msgList', this.msgList);
            console.log('filter pinglun end');
        }
    }
}

</script>


<style lang="scss" scoped>
.el-tooltip__popper.is-dark {
    position: absolute;
    z-index: 2010;
    padding: 8px 10px;
    max-width: 250px;
    color: #fff;
    background-color: black;
    border-radius: 4px;
    font-size: 12px;
    text-align: center;
    visibility: visible;
    opacity: 1;
    transition: visibility 0s, opacity 0.5s linear;

    /* 调整tooltip的位置 */
    bottom: auto;
    /* 根据需求调整 */
    top: auto;
    /* 根据需求调整 */
    left: 45% !important;
    /* 根据需求调整 */
    right: 10px;
    /* 根据需求调整 */
}

.el-table .el-table__body td {
    border-right: none;
}

.el-table .el-table__header-wrapper {
    position: sticky;
    top: 0;
    z-index: 999;
    background: #fff;
}

.yixuan {
    margin: 20px;
    color: #787878;
}

.addshuziren_btn {
    position: absolute;
    right: 0;
    margin-right: 50px;
}


.daorushuziren_btn {
    position: absolute;
    right: 0;
    margin-right: 230px;
}

.daorushuziren_btn2 {
    position: absolute;
    right: 0;
    margin-right: 140px;
}

.uploadcol {
    display: flex;
    flex-flow: column;
    width: 100px;
}

.uploadborder {
    border: 1px dashed #d9d9d9;
    border-radius: 6px;
    /* cursor: pointer;

    position: relative;

    overflow: hidden; */
    width: 100px;
    height: 100px;
}
</style>